﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/MasterPage.master" AutoEventWireup="true"
    CodeFile="UserList.aspx.cs" Inherits="admin_system_UserList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head_Title" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head" runat="Server">
    <%--<link href="/Plugin/flexigrid1.2/css/flexigrid.pack.css" rel="stylesheet" type="text/css" />
    <script src="/Plugin/flexigrid1.2/js/flexigrid.js" type="text/javascript"></script>--%>
    <script src="/Plugin/jqueryEasyui/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/Plugin/jqueryEasyui/datagrid-detailview.js" type="text/javascript"></script>
    <link href="/Plugin/jqueryEasyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Plugin/jqueryEasyui/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/sjn.1.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Title" runat="Server">
    系统管理 - 管理员管理
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Control" runat="Server">
    <input type="button" value="添加" onclick="AddAlter()" />
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Content" runat="Server">
    <script language="javascript" type="text/javascript">

        $(function () {

            $('#UserList').datagrid({
                url: "userlist.aspx?fun=GetAdminUserList",
                singleSelect: true,
                height: $("#UserList").parent().height(),
                columns: [[
                    { title: "用户名", field: "Account", width: 150, halign: "center" },
                    { title: "管理员姓名", field: "UserName", width: 150, halign: "center" },
                    { title: "Email", field: "Email", width: 200, halign: "center" },
                    { title: "状态", field: "IsDisabled", width: 70, align: "center",
                        formatter: function (value, row, index) {
                            if (value) {
                                return "开启";
                            } else {
                                return "禁用";
                            }
                        }
                    },
                    { title: "创建时间", field: "CreateTime", width: 140, align: "center",
                        formatter: function (value, row, index) {
                            return sjn.toDate(value).format();
                        }
                    },
                    { title: "操作", field: "tool", width: 200, align: "center",
                        formatter: function (value, row, index) {
                            var htm = '<a href="#" class="easyui-linkbutton" onclick="EditAlter(\'' + row.UserID + '\')" data-options="plain:true">编辑</a>';
                            return htm;
                        }
                    }
                ]],
                view: detailview,
                detailFormatter: function (index, row) {
                    return '<div style="padding:2px"><table class="ddv"></table></div>';
                },
                onExpandRow: function (index, row) {
                    var ddv = $(this).datagrid('getRowDetail', index).find('table.ddv');
                    ddv.datagrid({
                        url: 'userlist.aspx?fun=getAdminRolesByAdminId&uid=' + row.UserID,
                        title: "所拥有的角色",
                        fitColumns: true,
                        singleSelect: true,
                        rownumbers: true,
                        loadMsg: '',
                        height: 'auto',
                        columns: [[
                            { field: 'RoleName', title: '角色名称', width: 100 },
                            { field: 'RoleIntro', title: '说明', width: 100,
                                formatter: function (value, row, index) {
                                    if (value == "null") {
                                        return "";
                                    } else {
                                        return value;
                                    }
                                }
                            }
                        ]],
                        onResize: function () {
                            $('#UserList').datagrid('fixDetailRowHeight', index);
                        },
                        onLoadSuccess: function () {
                            setTimeout(function () {
                                $('#UserList').datagrid('fixDetailRowHeight', index);
                            }, 0);
                        }
                    });
                    $('#UserList').datagrid('fixDetailRowHeight', index);
                }
            });
        });



        //“添加” 按钮事件
        var AddAlter = function () {
            art.dialog.removeData("editData");
            art.dialog.open('<%=MyUrl.ToAb("~/Admin/system/") %>UserDetail.aspx?act=add',
                            {
                                title: "添加管理员",
                                id: 'AddAlter',
                                lock: true,
                                width: 610,
                                height: 325,
                                close: function () {
                                    var refresh = art.dialog.data("Refresh");
                                    if (refresh == "true") {
                                        location.href = location.href;
                                    }
                                }
                            });
        };


        //“编辑” 按钮事件
        var EditAlter = function (uid) {
            var data = $('#UserList').datagrid("getData");
            var editData;
            $(data.rows).each(function (i, item) {
                if (item.UserID == uid) {
                    editData = item;
                }
            });
            //获取要编辑的数据
            art.dialog.data("editData", editData);
            art.dialog.open('<%=MyUrl.ToAb("~/Admin/system/") %>UserDetail.aspx?act=edit&uid=' + uid,
                            {
                                title: "编辑管理员",
                                id: 'EditAlter',
                                lock: true,
                                width: 610,
                                height: 345,
                                close: function () {
                                    var refresh = art.dialog.data("Refresh");
                                    if (refresh == "true") {
                                        location.href = location.href;
                                    }
                                }
                            });
        };





    </script>
    <table id="UserList">
    </table>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Foot" runat="Server">
    <div id="div_page" runat="server">
    </div>
</asp:Content>
